﻿<!doctype html>
<html><!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>试驾预约</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/shopSelecterNew.js"></script>
<script type="text/javascript" src="../js/pagination.js"></script>
<script type="text/javascript" src="../js/find.js"></script>

	<link rel="stylesheet" href="../css/default.css" />
	<script type="text/javascript" src="../js/doubleDate2.0.js"></script> 
<script type="text/javascript">
$(function(){
	
	$('.doubledate').kuiDate({
		className:'doubledate',
		isDisabled: "0"  // isDisabled为可选参数，“0”表示今日之前不可选，“1”标志今日之前可选
	});

});
</script>
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<style type="text/css">
#window_change p label span img{
    border: 1px solid #CCCCCC;
    height: 51px;
    vertical-align: middle;
    width: 75px;

}

</style>

<script type="text/javascript" >
$(function(){
	$("#shopIsChoosed").click(function(){
		if($("#shopIsChoosed").is(":checked")){
			$("#shopName").attr("disabled",false);
			$("#research").attr("disabled",false);
			
		}else{
			$("#shopName").attr("disabled",true);

		}
	});
})
function  downRescouse(){
	var mp=$("#mp").val().replace(/\s/gi,'');	
	var custName=$("#custName").val().replace(/\s/gi,'');
	var userName=$("#userName").val();
	var dtBegin=$("#dtBegin").val();
	var dtEnd=$("#dtEnd").val();
	var carType=$("#carType").val();
	var shopId="";
	if($("#shopIsChoosed").is(":checked")){	
		shopId=$("#shopName").val();
		if(shopId!=""&&shopId!=null){
			
		}else{
			shopId="";
		}
	}
	
	var params = {'mp':mp,'custName':custName,'userName':userName,'dtBegin':dtBegin,'carType':carType,'shopId':shopId,'dtEnd':dtEnd}
	window.location.href="../tryRecord/export/csv?"+$.param(params)
	}
	




function deleteInfo(id){
	
		$.post("../shop/del/deleteShop",{"id":id}, function(data) {
			var dt = JSON.parse(data);
			if(IsEmpty(dt)){
				art.dialog({fixed:true, lock: true,content:"删除出错",icon:'error',ok:true});	
				return false;
				}
				if(dt.state==0){
					InitTable();
					art.dialog({fixed:true, lock: true,content:"删除成功",icon:'succeed',ok:true});	
				}else if(dt.state==1){
					art.dialog({fixed:true, lock: true,content:dt.msg,icon:'error',ok:true});	
				}else{
					checkStateShowErrorMsgAndDealResult(data);
				}
		});
	
}

	
	
function popPoint(id){
	art.dialog({fixed:true, lock: true,content:"确认删除该条数据？",icon:'question',ok: function(){ deleteInfo(id)},cancel:true});
	}

function search(){
	getTryDriverList(1)
}

function getTryDriverList (index){
	if(IsEmpty(index)){
		indexs=1
	}else{
		indexs = index
	}
	
	var mp=$("#mp").val().replace(/\s/gi,'');	
	var custName=$("#custName").val().replace(/\s/gi,'');
	var userName=$("#userName").val();
	var dtBegin=$("#dtBegin").val();
	var dtEnd=$("#dtEnd").val();
	var carType=$("#carType").val();
	var shopId="";
	if($("#shopIsChoosed").is(":checked")){	
		shopId=$("#shopName").val();
		if(shopId!=""&&shopId!=null){
			
		}else{
			shopId="";
		}
	}
	
	var params = {'mp':mp,'custName':custName,'userName':userName,'dtBegin':dtBegin,'carType':carType,'shopId':shopId,'dtEnd':dtEnd}
	resultJson = _findInfo("../tryRecord/find/tryRecordList/"+(indexs - 1)+"/10", params);
	if(IsNotEmpty(resultJson)&&resultJson.state==0){
		 $("#memberList tbody").empty()

		for ( var i = 0; i < resultJson.result.data.length; i++) {
			var htm="<tr>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "shopName")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "userName")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "custName")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "mp")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "trcTypeName")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "tryDate").substring(0,10)+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "timeName")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "memo")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "submitDate")+"</td>"
			 htm+="<td>"+_getStringOfJson(i, resultJson, "staName")+"</td>"
			 var state=_getIntOfJson(i, resultJson, "status")
			if(state==0){
				htm+="<td><input class=\"common_btn to_update\" type=\"button\" value=\"处理\" onclick='cl("+getHeadIndexValue(i, resultJson, "id")+",0)' ></td>"
			 }else{
				htm+="<td><input class=\"common_btn to_update\" type=\"button\" value=\"处理情况\" onclick='clqk("+getHeadIndexValue(i, resultJson, "id")+",0)' ></td>"
			 }
			 htm+="</tr>"
			 $("#memberList tbody").append(htm)
		}
/* 		_loadInfo(resultJson, "memberList", param)
 */		$("#memberList tbody tr").each(function(){
			
		})
		_loadPage("pager", indexs, 10, resultJson, getTryDriverList, "NoResult");
		$("#sup").html("共"+resultJson.result.len+"条");		
	}
}

function cl(id){
	$("#dealId").val(id)
	addMargin($("#replyWindow"))
	$("#yinying1,#replyWindow").show()
}

function reply(){
	var result = $("#result").val()
	var id = $("#dealId").val();
	var reply = $("#reply").val()
	var heads  = new Array("reply", "result","Status","id");
	var datas  = new Array(reply,result,2,id);
	var json = _getJsonParseEditStr(heads, datas);
	var dt = _editInfo("../tryRecord/edit/deal", {'data':json,'reply':reply})
	if(dt.state==0){
		$("#reply").val("")
		$("#result").val("")
		$("#yinying1,#replyWindow").hide()

		getTryDriverList(indexs);
	}
}
function clqk(id){
	for ( var i = 0; i < resultJson.result.data.length; i++) {
		var ids = getHtmlString(getHeadIndexValue(i, resultJson, "id"));
		if(id==ids){
			$("#resultShow").val(getHtmlString(getHeadIndexValue(i, resultJson, "result")))
			$("#replyShow").val(getHtmlString(getHeadIndexValue(i, resultJson, "reply")))
		}
	}
	addMargin($("#replyShowDiv"))
	$('#yinying1,#replyShowDiv').show()
}

</script>
</head>

<body>
<div id="yinying1"></div>
<div id="replyShowDiv" class="hideDiv">
			<div class="closeTop">
				<span id="closeThe"><img onclick="$('#yinying1,#replyShowDiv').hide()" src="../images/close.png"></span>
			</div>
			<div>
				<p>
					<label>回复客户：</label>
					<br />
					<textarea id="replyShow" style="width: 90%; height: 150px;" readonly="readonly"></textarea>
				</p>
				<p>
					<label>处理结果：</label>
					<br />
					<input type="hidden" value="" id= "dealId">
					<textarea id="resultShow" style="width: 90%; height: 150px;" readonly="readonly"></textarea>
				</p>
				<p class="BottomBtn">
					<input type = "button" value="确定" onclick="$('#yinying1,#replyShowDiv').hide()">
				</p>
			</div>
		</div>		
		<div id="replyWindow" class="hideDiv">
			<div class="closeTop">
				<span id="closeThe"><img onclick="$('#yinying1,#replyWindow').hide()" src="../images/close.png"></span>
			</div>
			<div>
				<p>
					<label>回复客户：</label>
					<br />
					<textarea id="reply" style="width: 90%; height: 150px;"></textarea>
				</p>
				<p>
					<label>处理结果：</label>
					<br />
					<input type="hidden" value="" id= "dealId">
					<textarea id="result" style="width: 90%; height: 150px;"></textarea>
				</p>
				<p class="BottomBtn">
					<input type = "button" value="确定" onclick="reply();">
				</p>
			</div>
		</div>
<div class="container" id="container">
  <div class="container_R fr">
	<div class="place">试驾预约</div>
    <div class="member_search">

    <p>
   <span>
        <input type="checkbox" id="shopIsChoosed" style="width:auto;height:auto;border:none;">店面：</span>
        <select id="shopName" onclick="openShopListPanel(this)" disabled="disabled">
        </select>
        <span>起始日期：</span>
        <input type="text" readonly class="doubledate ipticon"  id="dtBegin"/>
        <span>截止时间：</span>
        <input type="text" readonly class="doubledate ipticon" id="dtEnd"/>
        </p>
        <p><span>销售顾问：</span>
                <input type="text" id="userName" class="absoluteTxt">
        <span>预约人姓名：</span>
                 <input type="text" id="custName" class="absoluteTxt">
        <span>预约人电话：</span>
                 <input type="text" id="mp" class="absoluteTxt">
        </p><p>
        <span>车型：</span>
                 <input type="text" id="carType" class="absoluteTxt">
        <input type="button" value="查询" class="btn" onclick="search()"></p></div>
    
    <table width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="memberList">
    	<caption><strong>试驾预约列表        <span id="sup">共0条</span> </strong>  <a href="javascript:void(0)" onclick="downRescouse();">导出数据</a> </caption>
    	<thead>
    	<tr>
    		<th width="50">店面</th>
        	<th width="30">销售顾问</th>
        	<th width="50">姓名</th>
        	<th width="50">手机</th>
        	<th width="50">车型</th>
        	<th width="50">预约日期</th>
        	<th width="50">预约时间</th>
        	<th width="50">备注</th>
        	<th width="36">提交时间</th>
        	<th width="40">状态</th>
        	<th width="40">操作</th>
        </tr>
        </thead>
        <tbody>
        	
        </tbody>
    </table>
    <div id="NoResult"  class="Nothing" style="text-align:center;display: none;">无符合条件的数据！</div>
    <div id="pager" style="float: right;"></div>
  </div>
  <div class="fc"></div>
</div>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/header.js"></script>
<script type="text/javascript" src="../js/left.js"></script>
<script type="text/javascript" src="../js/footer.js"></script>
<script type="text/javascript">
clearThis("absoluteTxt");
showTab(1,1);
</script>
</body>
<!-- InstanceEnd --></html>
